package top.happylaishop.shop.utils.resp;

import top.happylaishop.shop.common.Const;

public class BaseResponse implements java.io.Serializable {

    public static BaseResponse OK = new BaseResponse(Const.HTTP_OK, Const.DEFAULT_SUCCESS_MSG);
    public static BaseResponse FAIL = new BaseResponse(Const.HTTP_SERVER_ERROR, Const.DEFAULT_ERROR_MSG);
    public static BaseResponse LIMIT = new BaseResponse(Const.HTTP_REQUEST_LIMIT, Const.DEFAULT_LIMIT_MSG_REPLY);

    private int status = 200;
    private String message;

    public BaseResponse(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public BaseResponse() {
    }

    public static BaseResponse failed(String msg) {
        return new BaseResponse(500, msg);
    }

    public static BaseResponse failed() {
        return FAIL;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public static BaseResponse success() {
        return OK;
    }

    public boolean isSuccess(){
        return getStatus () == 200;
    }
}